package com.nefu.store.common.handler;


import com.nefu.store.common.exception.user.UserCredentialException;
import com.nefu.store.common.exception.user.UsernameEmptyException;
import com.nefu.store.common.exception.user.UsernameNotFoundException;
import com.nefu.store.common.result.HttpResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class NefuMusicExceptionHandler {


    @ExceptionHandler(UsernameEmptyException.class)
    public HttpResult<String> usernameEmptyException(UsernameEmptyException e) {
        log.error(e.getMessage());
        return HttpResult.failed(e.getMessage());
    }

    @ExceptionHandler(UsernameNotFoundException.class)
    public HttpResult<String> usernameNotFoundException(UsernameNotFoundException e) {
        log.error(e.getMessage());
        return HttpResult.failed(e.getMessage());
    }

    @ExceptionHandler(UserCredentialException.class)
    public HttpResult<String> userCredentialException(UserCredentialException e) {
        log.error(e.getMessage());
        return HttpResult.failed(e.getMessage());
    }

}
